<?php
namespace User;
use Zend\ModuleManager\ModuleManager;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\Stdlib\Hydrator\ClassMethods;
//use Zend\Mvc\MvcEvent;

class Module  implements
    AutoloaderProviderInterface,
    ConfigProviderInterface,
    ServiceProviderInterface
{

    /**
     * {@inheritDoc}
     */
    /*
    public function onBootstrap(MvcEvent $e)
    {
        $translator = $e->getApplication()->getServiceManager()->get('translator');
        $eventManager = $e->getApplication()->getEventManager();
        //$moduleRouteListener = new ModuleRouteListener();
        //$moduleRouteListener->attach($eventManager);
        //$app = $e->getParam('application');
        //$app->getEventManager()->attach('render', array($this, 'setLayoutTitle'));
        //$translator->setLocale('ja_JP');
        echo $translator->getLocale();
    }*/

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                ),
            ),
        );
    }

    public function getControllerPluginConfig()
    {
        return array(
            'factories' => array(
                'UserAuthentication' => 'User\Factory\Controller\Plugin\UserAuthenticationFactory',
            ),
        );
    }

    public function getViewHelperConfig()
    {
        return array(
            'factories' => array(
                'UserDisplayName' => 'User\Factory\View\Helper\DisplayNameFactory',
                'UserIdentity' => 'User\Factory\View\Helper\IdentityFactory',
            )
        );
    }

    public function getServiceConfig()
    {
        return array(
            'invokables' => array(
                'user_service' => 'User\Service\User',
                'User\Authentication\Adapter\Db' => 'User\Authentication\Adapter\Db',
                'User\Authentication\Storage\Db' => 'User\Authentication\Storage\Db',
            ),
            'factories' => array(
                'user_register_form'    => 'User\Factory\Form\RegisterFormFactory',
                'user_login_form'       => 'User\Factory\Form\LoginFormFactory',
                'user_module_options'   => 'User\Factory\ModuleOptionsFactory',
                'user_hydrator'         => 'User\Factory\Mapper\UserHydratorFactory',
                'user_mapper'           => 'User\Factory\UserMapperFactory',
                'user_auth_service'                          => 'User\Factory\AuthenticationServiceFactory',
                'User\Authentication\Adapter\AdapterChain'   => 'User\Authentication\Adapter\AdapterChainServiceFactory',
            ),
        );
    }
}
